# // ***************************************************************************
# // 
# // Copyright (c) Scriptimus Ex Machina.  All rights reserved.
# // 
# // Microsoft Deployment Toolkit Support Script
# //
# // File:      ZTIAddDNSRecords.ps1
# // 
# // Version:   1.00 
# // 
# // Purpose:   Creates DNS resource records
# // 
# // ***************************************************************************

<#
.Synopsis
   Add DNS Record
.DESCRIPTION
   Adds a resource record to a DNS zone. This script is a wrapper for the COM object dnscmd with the switch /recordadd 
   The useage is as followe:
   dnscmd [<ServerName>] /recordadd <ZoneName> <NodeName> <RRType> <RRData>

   This script is a wrapper for DNSCMD.EXE information
   can be found on technet http://technet.microsoft.com/en-us/library/cc772069(v=ws.10).aspx
.EXAMPLE
    ZTIAddDNSRecords.ps1 "isp.example.com INET1 A 131.107.0.1"

    This example adds a Zone A record to the DNS zone isp.example.com 
    The Syntax is : <ZoneName> <NodeName> <RRType> <RRData>  
.EXAMPLE
   For MDT, if you create a list pf propertys in the customsettings.ini this script will cycle through and create each record
   DNSRecord001 = isp.example.com INET1 A 131.107.0.1
   DNSRecord002 = corp.continuum.com EDGE1 A 131.107.0.2
   
   The command line would then be
   ZTIAddDNSRecords.ps1 -record = $tsenvlist:DNSRecord
.NOTES
   Author: Andrew Barnes
   Version: 1.0
   Created: 11 November 2012
   Last updated: 11 November 2012
   Website: http:\\scriptimus.wordpress.com

#>
    [CmdletBinding()]

    [OutputType([int])]

    Param (

        # DNSRecord parameter. Syntax: <ZoneName> <NodeName> <RRType> <RRData>

        [Parameter(Mandatory=$true,

                   Position=0)]

        [String[]]$Record = $tsenvlist:DNSRECORD

        )

    Begin {

        Write-Host "Begining script"
        
        }

    Process {

        Write-Host "Processing Script"
    
        $Record | foreach {
    
            Write-host "Adding DNS Record $Record"
    
            $ZoneAdd = "dnscmd /recordadd $_"

            Write-Host "About to execute command: $ZoneAdd"
    
            Invoke-Expression $ZoneAdd | Tee-Object -Variable Result

            Write-Host "Command completed with result: $Result `n `n"
    
            }
    
        }
    
    End {
    
        Write-Host "End Script"
        }
 